
***************************************** GRAVITY MODELS ***********************************************

clear all
set more off
set scheme plotplainblind
macro drop _all
estimates drop _all
set matsize 800
set seed 8675309

cd "~/Dropbox/Immigration/Analysis/Gravity Models/"
      
use "ddyadic_dwrap.dta", clear
estimates drop _all

** Covariate Macros

global dv "combinedrate"

global iv "policy5ma access5ma services5ma livelihoods5ma movement5ma participation5ma" 

global dyadic "ihs_distance contiguous tek comlang ihs_mighist africa_dyad me_dyad sasia_dyad" 

global dyadnum "ihs_distance contiguous comlang ihs_mighist africa_dyad me_dyad sasia_dyad" 

global dyad92 "ihs_distance contiguous comlang ihs_mighist africa_dyad me_dyad sasia_dyad" 

global base "ihs_coo_pophth ihs_coa_pophth"

global mid "ihs_coo_pophth ihs_coa_pophth ihs_gdppcratio_lag1 ihs_sq_gdppcratio_lag1 ihs_coo_unemployilo_lag1 ihs_coa_unemployilo_lag1"

global full "ihs_coo_pophth ihs_coa_pophth ihs_gdppcratio_lag1 ihs_sq_gdppcratio_lag1 ihs_coo_unemployilo_lag1 ihs_coa_unemployilo_lag1 civilwarbroad1_lag1 civilwarbroad2_lag1 rev_fariss1_lag1 rev_fariss2_lag1"

global itsa "ihs_gdppc_lag1 polyarchy_lag1 ihs_pop_lag1 fariss_repression_lag1 ihs_unemployilo_lag1 cwbroad_lag1 majoranncwbroad_reg1500_lag1"

xtset dyad_id year


************************************** SUMMARY STATISTICS **********************************************


estpost sum $dv $iv $info $dyadic $full

esttab using "~/Desktop/sumstat_gravity.tex", label title(Summary Statistics) cells("count mean sd min max")


********************************************************** Main Gravity **********************************************************************************************************************************************************

eststo main: ppmlhdfe combinedrate c.policy5ma $dyadic $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/main.tex", tex(land) label dec(3) replace ctitle(PPML) keep(c.policy5ma $dyadic $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo ewmain: ppmlhdfe combinedrate c.ewpolicy5ma $dyadic $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/main.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.ewpolicy5ma $dyadic $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo policy1: qui poisson combinedrate c.policy5ma $dyadic $full i.ccode1 i.ccode2 i.year, cluster(dyad_id)
eststo policy1marg: margins, at(policy5ma = (0 .0283096 .1123505 .2056621 .3340973)) atmeans post vsquish

eststo policy2: qui poisson combinedrate c.ewpolicy5ma $dyadic $full i.ccode1 i.ccode2 i.year, cluster(dyad_id)
eststo policy2marg: margins, at(ewpolicy5ma = (0 .0400662 .1367699 .2661132 .4274449)) atmeans post vsquish

coefplot policy1marg policy2marg, ci(95) xline(0, lcolor(cranberry) lpatt(shortdash)) ms(O) msize(medlarge) ciopts(lwidth(.4 .75)) xtitle("Predicted FDP Arrival Rate" "(Per 100,000s of Origin Population)", size(medsmall)) ytitle("Displacement Policy Liberality", size(medsmall)) ylabel(1 "10th Percentile" 2 "25th Percentile" 3 "50th Percentile" 4 "75th Percentile" 5 "90th Percentile") xlabel(-0.0001 "-0.0001" 0 "0" 0.0001 "0.0001" 0.0002 "0.0002" .0003 "0.0003" .0004 "0.0004", angle(h) tlength(*1.45)) xmtick(-.0001(.00005).0004, tlength(*1.75)) legend(off)


********************************************************** Conditional Gravity **********************************************************************************************************************************************************

eststo info: ppmlhdfe combinedrate c.policy5ma##highinfo_coo $dyadic $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/conditional.tex", tex(land) label dec(3) replace ctitle(PPML) keep(c.policy5ma##highinfo_coo $dyadic $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo ewinfo: ppmlhdfe combinedrate c.ewpolicy5ma##highinfo_coo $dyadic $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/conditional.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.ewpolicy5ma##highinfo_coo $dyadic $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo tek: ppmlhdfe combinedrate c.policy5ma##tek $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/conditional.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.policy5ma##tek $dyadnum $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo ewtek: ppmlhdfe combinedrate c.ewpolicy5ma##tek $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/conditional.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.ewpolicy5ma##tek $dyadnum $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo teknum: ppmlhdfe combinedrate c.policy5ma##c.teknum $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/conditional.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.policy5ma##c.teknum $dyadnum $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo ewteknum: ppmlhdfe combinedrate c.ewpolicy5ma##c.teknum $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/conditional.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.ewpolicy5ma##c.teknum $dyadnum $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')


********************************************************** Policy x Facilitator Substantive Effects **********************************************************************************************************************************************************

eststo info1: qui poisson combinedrate c.policy5ma##highinfo_coo tek $dyadic $full i.ccode1 i.ccode2 i.year, cluster(dyad_id)
eststo info1marg: qui margins, dydx(highinfo_coo) at(policy5ma = (0 .0283096 .1123505 .2056621 .3340973)) atmeans post vsquish

eststo tek1: qui poisson combinedrate c.policy5ma##tek $dyadnum $full i.ccode1 i.ccode2 i.year, cluster(dyad_id)
eststo tek1marg: qui margins, dydx(tek) at(policy5ma = (0 .0283096 .1123505 .2056621 .3340973)) atmeans post vsquish

eststo teknum1: qui poisson combinedrate c.policy5ma##c.teknum $dyadnum $full i.ccode1 i.ccode2 i.year, cluster(dyad_id) diff
eststo teknummarg1: qui margins, dydx(teknum) at(policy5ma = (0 .0283096 .1123505 .2056621 .3340973)) atmeans post vsquish


*coefplot info1marg, ci(90) xline(0, lcolor(cranberry) lpatt(shortdash)) ms(O) msize(medlarge) ciopts(lwidth(.4 .75)) xtitle("AME on FDP Arrival Rate" "(Per 100,000s of Origin Population)", size(medsmall)) ytitle("Displacement Policy Score", size(medsmall)) ylabel(1 "10th Percentile" 2 "25th Percentile" 3 "50th Percentile" 4 "75th Percentile" 5 "90th Percentile") xlabel(-0.0005 "-0.0005" -0.0004 "-0.0004" -0.0003 "-0.0003" -0.0002 "-0.0002" -0.0001 "-0.0001" 0 "0" 0.0001 "0.0001" 0.0002 "0.0002", angle(h) tlength(*1.45)) xmtick(-.0005(.00005).0002, tlength(*1.75)) legend(off)
*coefplot tek1marg, ci(90) xline(0, lcolor(cranberry) lpatt(shortdash)) ms(O) msize(medlarge) ciopts(lwidth(.4 .75)) xtitle("AME on FDP Arrival Rate" "(Per 100,000s of Origin Population)", size(medsmall)) ytitle("Displacement Policy Score", size(medsmall)) ylabel(1 "10th Percentile" 2 "25th Percentile" 3 "50th Percentile" 4 "75th Percentile" 5 "90th Percentile") xlabel(-0.0002 "-0.0002" -0.0001 "-0.0001" 0 "0" 0.0001 "0.0001" 0.0002 "0.0002" 0.0003 "0.0003" 0.0004 "0.0004" 0.0005 "0.0005", angle(h) tlength(*1.45)) xmtick(-.0002(.00005).0005, tlength(*1.75)) legend(off)
*coefplot teknummarg1, ci(90) xline(0, lcolor(cranberry) lpatt(shortdash)) ms(O) msize(medlarge) ciopts(lwidth(.4 .75)) xtitle("AME on FDP Arrival Rate" "(Per 100,000s of Origin Population)", size(medsmall)) ytitle("Displacement Policy Score", size(medsmall)) ylabel(1 "10th Percentile" 2 "25th Percentile" 3 "50th Percentile" 4 "75th Percentile" 5 "90th Percentile") xlabel(-0.0002 "-0.0002" -0.0001 "-0.0001" 0 "0" 0.0001 "0.0001" 0.0002 "0.0002", angle(h) tlength(*1.45)) xmtick(-.0002(.00005).0002, tlength(*1.75)) legend(off)

coefplot (info1marg, msymbol(S) mfcolor(white) mlcolor(black) msize(medium) ciopts(lcolor(black black) lwidth(.45 .9))), bylabel(Information Openness) || (tek1marg, msymbol(O) mfcolor(white) mlcolor(black) msize(medium) ciopts(lcolor(black black) lwidth(.45 .9))), bylabel(TEK Presence) || (teknummarg1, msymbol(D) mfcolor(white) mlcolor(black) msize(medlarge) ciopts(lcolor(black black) lwidth(.45 .9))),  bylabel(# of TEK) norecycle ci(95 90) byopts(cols(3) yrescale) vert legend(off) xlabel(1 "10th" 2 "25th" 3 "50th" 4 "75th" 5 "90th")


********************************************************** Accounting for Diffusion **********************************************************************************************************************************************************

** Control for Regional Diffusion

ppmlhdfe combinedrate c.policy5ma##highinfo_coo $dyadic $full reglib1last3, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/diffusion.tex", tex(land) label dec(3) replace ctitle(PPML) keep(c.policy5ma##highinfo_coo $dyadic $full reglib1last3) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

ppmlhdfe combinedrate c.policy5ma##tek $dyadnum $full reglib1last3, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/diffusion.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.policy5ma##tek $dyadnum $full reglib1last3) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

ppmlhdfe combinedrate c.policy5ma##c.teknum $dyadnum $full reglib1last3, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/diffusion.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.policy5ma##c.teknum $dyadnum $full reglib1last3) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

** IPTW

* use "/Users/christopherblair/Dropbox/Immigration/Analysis/Policy Diffusion/dwrap_index_final.dta"
* probit liberalization1 exc1inc2_reg_lag1 ihs_aidgdp_5ma_wins ihs_gdppc_lag1 neggdpshock_lag1 ihs_pop_lag1 std_polyarchy_lag1 cwbroad_lag1 ihs_iterate_lag1 ihs_tradeshare_lag1 majorannintra_contig_lag1 numlib1 c.lib1_end##c.lib1_end##c.lib1_end, vce(cluster ccode2)
* predict pr_lib, p
* gen iptw=.
* replace iptw=1/pr_lib if liberalization1==1
* replace iptw=1/(1-pr_lib) if liberalization1==0

ppmlhdfe combinedrate c.policy5ma##highinfo_coo $dyadic $full [pw=iptw], cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/diffusion.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.policy5ma##highinfo_coo $dyadic $full reglib1last3) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

ppmlhdfe combinedrate c.policy5ma##tek $dyadnum $full [pw=iptw], cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/diffusion.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.policy5ma##tek $dyadnum $full reglib1last3) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

ppmlhdfe combinedrate c.policy5ma##c.teknum $dyadnum $full [pw=iptw], cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/diffusion.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.policy5ma##c.teknum $dyadnum $full reglib1last3) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')


********************************************************** ONLY PRIMA FACIE ARRIVALS **********************************************************************************************************************************************************

ppmlhdfe shaverrate c.policy5ma##highinfo_coo $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/pfacie.tex", tex(land) label dec(3) replace ctitle(PPML) keep(c.policy5ma##highinfo_coo $dyadic $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

ppmlhdfe shaverrate c.policy5ma##tek $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/pfacie.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.policy5ma##tek $dyadic $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

ppmlhdfe shaverrate c.policy5ma##c.teknum $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/pfacie.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.policy5ma##c.teknum $dyadic $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')


********************************************************** Disaggregating Policy **********************************************************************************************************************************************************

gen facilitator=highinfo_coo

gen policy=access5ma
gen polxfac=policy*facilitator
eststo info1: ppmlhdfe combinedrate polxfac policy facilitator $dyadic $full, cluster(dyad_id) abs(ccode1 ccode2 year)
drop policy polxfac

gen policy=services5ma
gen polxfac=policy*facilitator
eststo info2: ppmlhdfe combinedrate polxfac policy facilitator $dyadic $full, cluster(dyad_id) abs(ccode1 ccode2 year)
drop policy polxfac

gen policy=livelihoods5ma
gen polxfac=policy*facilitator
eststo info3: ppmlhdfe combinedrate polxfac policy facilitator $dyadic $full, cluster(dyad_id) abs(ccode1 ccode2 year)
drop policy polxfac

gen policy=movement5ma
gen polxfac=policy*facilitator
eststo info4: ppmlhdfe combinedrate polxfac policy facilitator $dyadic $full, cluster(dyad_id) abs(ccode1 ccode2 year)
drop policy polxfac

gen policy=participation5ma
gen polxfac=policy*facilitator
eststo info5: ppmlhdfe combinedrate polxfac policy facilitator $dyadic $full, cluster(dyad_id) abs(ccode1 ccode2 year)
drop policy polxfac
drop facilitator


gen facilitator=tek

gen policy=access5ma
gen polxfac=policy*facilitator
eststo tek1: ppmlhdfe combinedrate polxfac policy facilitator $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
drop policy polxfac

gen policy=services5ma
gen polxfac=policy*facilitator
eststo tek2: ppmlhdfe combinedrate polxfac policy facilitator $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
drop policy polxfac

gen policy=livelihoods5ma
gen polxfac=policy*facilitator
eststo tek3: ppmlhdfe combinedrate polxfac policy facilitator $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
drop policy polxfac

gen policy=movement5ma
gen polxfac=policy*facilitator
eststo tek4: ppmlhdfe combinedrate polxfac policy facilitator $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
drop policy polxfac

gen policy=participation5ma
gen polxfac=policy*facilitator
eststo tek5: ppmlhdfe combinedrate polxfac policy facilitator $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
drop policy polxfac
drop facilitator


gen facilitator=teknum

gen policy=access5ma
gen polxfac=policy*facilitator
eststo teknum1: ppmlhdfe combinedrate polxfac policy facilitator $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
drop policy polxfac

gen policy=services5ma
gen polxfac=policy*facilitator
eststo teknum2: ppmlhdfe combinedrate polxfac policy facilitator $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
drop policy polxfac

gen policy=livelihoods5ma
gen polxfac=policy*facilitator
eststo teknum3: ppmlhdfe combinedrate polxfac policy facilitator $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
drop policy polxfac

gen policy=movement5ma
gen polxfac=policy*facilitator
eststo teknum4: ppmlhdfe combinedrate polxfac policy facilitator $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
drop policy polxfac

gen policy=participation5ma
gen polxfac=policy*facilitator
eststo teknum5: ppmlhdfe combinedrate polxfac policy facilitator $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
drop policy polxfac
drop facilitator

*coefplot (info1, msymbol(O) mcolor(black) lcolor(black)) (tek1, msymbol(S) mcolor(gs12) lcolor(gs12)) (teknum1, msymbol(D) mcolor(gs8) lcolor(gs8)) || (info2, msymbol(O) mcolor(black) lcolor(black)) (tek2, msymbol(S) mcolor(gs12) lcolor(gs12)) (teknum2, msymbol(D) mcolor(gs8) lcolor(gs8)) || (info3, msymbol(O) mcolor(black) lcolor(black)) (tek3, msymbol(S) mcolor(gs12) lcolor(gs12)) (teknum3, msymbol(D) mcolor(gs8) lcolor(gs8)) || (info4, msymbol(O) mcolor(black) lcolor(black)) (tek4, msymbol(S) mcolor(gs12) lcolor(gs12)) (teknum4, msymbol(D) mcolor(gs8) lcolor(gs8)) || (info5, msymbol(O) mcolor(black) lcolor(black)) (tek5, msymbol(S) mcolor(gs12) lcolor(gs12)) (teknum5, msymbol(D) mcolor(gs8) lcolor(gs8)), ci(95) keep(c.facilitator#c.policy 1.facilitator#c.policy) vert byopts(row(1)) ylabel(-4(2)10) ymtick(-4(1)11, tlength(*1.75)) yline(0, lcolor(cranberry) lpatt(shortdash))


********************************************************** Disaggregating Policy Margins **********************************************************************************************************************************************************

gen facilitator=highinfo_coo

gen policy=access5ma
poisson combinedrate c.policy##facilitator $dyadic $full i.ccode1 i.ccode2 i.year, cluster(dyad_id) diff
eststo access1: qui margins, dydx(facilitator) at(policy = (0 .0930854 .2022252 .4180176 .6446925 )) atmeans post vsquish
drop policy

gen policy=services5ma
poisson combinedrate c.policy##facilitator $dyadic $full i.ccode1 i.ccode2 i.year, cluster(dyad_id) diff
eststo services1: qui margins, dydx(facilitator) at(policy = (0 .0000001 .0480132 .1637481 .320226 )) atmeans post vsquish
drop policy

gen policy=livelihoods5ma
poisson combinedrate c.policy##facilitator $dyadic $full i.ccode1 i.ccode2 i.year, cluster(dyad_id) diff
eststo lhood1: qui margins, dydx(facilitator) at(policy = (0 .0000001 .016845 .1903377 .2710805 )) atmeans post vsquish
drop policy

gen policy=movement5ma
poisson combinedrate c.policy##facilitator $dyadic $full i.ccode1 i.ccode2 i.year, cluster(dyad_id) diff
eststo move1: qui margins, dydx(facilitator) at(policy = (0 .0000001 .3396605 .5726223 .6852041 )) atmeans post vsquish
drop policy

gen policy=participation5ma
poisson combinedrate c.policy##facilitator $dyadic $full i.ccode1 i.ccode2 i.year, cluster(dyad_id) diff
eststo part1: qui margins, dydx(facilitator) at(policy = (0 .0000001 .00000015 .0904275 .1486882 )) atmeans post vsquish
drop policy
drop facilitator


gen facilitator=tek

gen policy=access5ma
poisson combinedrate c.policy##facilitator $dyadnum $full i.ccode1 i.ccode2 i.year, cluster(dyad_id) diff
eststo access2: qui margins, dydx(facilitator) at(policy = (0 .0930854 .2022252 .4180176 .6446925 )) atmeans post vsquish
drop policy

gen policy=services5ma
poisson combinedrate c.policy##facilitator $dyadnum $full i.ccode1 i.ccode2 i.year, cluster(dyad_id) diff
eststo services2: qui margins, dydx(facilitator) at(policy = (0 .0000001 .0480132 .1637481 .320226 )) atmeans post vsquish
drop policy

gen policy=livelihoods5ma
poisson combinedrate c.policy##facilitator $dyadnum $full i.ccode1 i.ccode2 i.year, cluster(dyad_id) diff
eststo lhood2: qui margins, dydx(facilitator) at(policy = (0 .0000001 .016845 .1903377 .2710805 )) atmeans post vsquish
drop policy

gen policy=movement5ma
poisson combinedrate c.policy##facilitator $dyadnum $full i.ccode1 i.ccode2 i.year, cluster(dyad_id) diff
eststo move2: qui margins, dydx(facilitator) at(policy = (0 .0000001 .3396605 .5726223 .6852041 )) atmeans post vsquish
drop policy

gen policy=participation5ma
poisson combinedrate c.policy##facilitator $dyadnum $full i.ccode1 i.ccode2 i.year, cluster(dyad_id) diff
eststo part2: qui margins, dydx(facilitator) at(policy = (0 .0000001 .00000015 .0904275 .1486882 )) atmeans post vsquish
drop policy
drop facilitator


gen facilitator=teknum

gen policy=access5ma
poisson combinedrate c.policy##c.facilitator $dyadnum $full i.ccode1 i.ccode2 i.year, cluster(dyad_id) diff
eststo access3: qui margins, dydx(facilitator) at(policy = (0 .0930854 .2022252 .4180176 .6446925 )) atmeans post vsquish
drop policy

gen policy=services5ma
poisson combinedrate c.policy##c.facilitator $dyadnum $full i.ccode1 i.ccode2 i.year, cluster(dyad_id) diff
eststo services3: qui margins, dydx(facilitator) at(policy = (0 .0000001 .0480132 .1637481 .320226 )) atmeans post vsquish
drop policy

gen policy=livelihoods5ma
poisson combinedrate c.policy##c.facilitator $dyadnum $full i.ccode1 i.ccode2 i.year, cluster(dyad_id) diff
eststo lhood3: qui margins, dydx(facilitator) at(policy = (0 .0000001 .016845 .1903377 .2710805 )) atmeans post vsquish
drop policy

gen policy=movement5ma
poisson combinedrate c.policy##c.facilitator $dyadnum $full i.ccode1 i.ccode2 i.year, cluster(dyad_id) diff
eststo move3: qui margins, dydx(facilitator) at(policy = (0 .0000001 .3396605 .5726223 .6852041 )) atmeans post vsquish
drop policy

gen policy=participation5ma
poisson combinedrate c.policy##c.facilitator $dyadnum $full i.ccode1 i.ccode2 i.year, cluster(dyad_id) diff
eststo part3: qui margins, dydx(facilitator) at(policy = (0 .0000001 .00000015 .0904275 .1486882 )) atmeans post vsquish
drop policy
drop facilitator

coefplot  access1 access2 access3, ci(95) xline(0, lcolor(cranberry) lpatt(shortdash)) ms(O) msize(medlarge) ciopts(lwidth(.4 .75)) ytitle("Displacement Policy Liberality", size(medsmall)) ylabel(1 "10th Percentile" 2 "25th Percentile" 3 "50th Percentile" 4 "75th Percentile" 5 "90th Percentile") xlabel(-0.0004 " " -0.0003 "-0.0003" -0.0002 " " -0.0001 "-0.0001" 0 "0" 0.0001 "0.0001" 0.0002 " " .0003 "0.0003" .0004 " " .0005 "0.0005" .0006 " " .0007 "0.0007", angle(h) tlength(*1.45)) xmtick(-.0004(.00005).0007, tlength(*1.75)) legend(off)
coefplot  services1 services2 services3, ci(95) xline(0, lcolor(cranberry) lpatt(shortdash)) ms(O) msize(medlarge) ciopts(lwidth(.4 .75)) ytitle("Displacement Policy Liberality", size(medsmall)) ylabel(1 "10th Percentile" 2 "25th Percentile" 3 "50th Percentile" 4 "75th Percentile" 5 "90th Percentile") xlabel(-0.0004 "-0.0004" -0.0003 "-0.0003" -0.0002 "-0.0002" -0.0001 "-0.0001" 0 "0" 0.0001 "0.0001" 0.0002 "0.0002" .0003 "0.0003" .0004 "0.0004" .0005 "0.0005", angle(h) tlength(*1.45)) xmtick(-.0004(.00005).0005, tlength(*1.75)) legend(off)
coefplot  lhood1 lhood2 lhood3, ci(95) xline(0, lcolor(cranberry) lpatt(shortdash)) ms(O) msize(medlarge) ciopts(lwidth(.4 .75)) ytitle("Displacement Policy Liberality", size(medsmall)) ylabel(1 "10th Percentile" 2 "25th Percentile" 3 "50th Percentile" 4 "75th Percentile" 5 "90th Percentile") xlabel(-0.0006 "-0.0006" -0.0005 " " -0.0004 "-0.0004" -0.0003 " " -0.0002 "-0.0002" -0.0001 " " 0 "0" 0.0001 " " 0.0002 "0.0002" .0003 " " .0004 "0.0004", angle(h) tlength(*1.45)) xmtick(-.0006(.00005).0004, tlength(*1.75)) legend(off)
coefplot  move1 move2 move3, ci(95) xline(0, lcolor(cranberry) lpatt(shortdash)) ms(O) msize(medlarge) ciopts(lwidth(.4 .75)) ytitle("Displacement Policy Liberality", size(medsmall)) ylabel(1 "10th Percentile" 2 "25th Percentile" 3 "50th Percentile" 4 "75th Percentile" 5 "90th Percentile") xlabel(-0.0006 "-0.0006" -0.0005 " " -0.0004 "-0.0004" -0.0003 " " -0.0002 "-0.0002" -0.0001 " " 0 "0" 0.0001 " " 0.0002 "0.0002" .0003 " " .0004 "0.0004", angle(h) tlength(*1.45)) xmtick(-.0006(.00005).0004, tlength(*1.75)) legend(off)
coefplot  part1 part2 part3, ci(95) xline(0, lcolor(cranberry) lpatt(shortdash)) ms(O) msize(medlarge) ciopts(lwidth(.4 .75)) ytitle("Displacement Policy Liberality", size(medsmall)) ylabel(1 "10th Percentile" 2 "25th Percentile" 3 "50th Percentile" 4 "75th Percentile" 5 "90th Percentile") xlabel(-0.0004 "-0.0004" -0.0003 "-0.0003" -0.0002 "-0.0002" -0.0001 "-0.0001" 0 "0" 0.0001 "0.0001" 0.0002 "0.0002" .0003 "0.0003" .0004 "0.0004", angle(h) tlength(*1.45)) xmtick(-.0004(.00005).0004, tlength(*1.75)) legend(off)



********************************************************** 5 Yr. Lag Gravity **********************************************************************************************************************************************************

eststo info5: ppmlhdfe combinedrate c.policy5lag##highinfo_coo $dyadic $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/main5.tex", tex(land) label dec(3) replace ctitle(PPML) keep(c.policy5lag##highinfo_coo $dyadic $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo ewinfo5: ppmlhdfe combinedrate c.ewpolicy5lag##highinfo_coo $dyadic $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/main5.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.ewpolicy5lag##highinfo_coo $dyadic $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo tek5: ppmlhdfe combinedrate c.policy5lag##tek $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/main5.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.policy5lag##tek $dyadnum $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo ewtek5: ppmlhdfe combinedrate c.ewpolicy5lag##tek $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/main5.tex", tex(land) label dec(3) append ctitle(PPML)keep(c.ewpolicy5lag##tek $dyadnum $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo teknum5: ppmlhdfe combinedrate c.policy5lag##c.teknum $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/main5.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.policy5lag##c.teknum $dyadnum $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo ewteknum5: ppmlhdfe combinedrate c.ewpolicy5lag##c.teknum $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/main5.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.ewpolicy5lag##c.teknum $dyadnum $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')


********************************************************** 3 Yr. Lag Gravity **********************************************************************************************************************************************************

eststo info3: ppmlhdfe combinedrate c.policy3lag##highinfo_coo $dyadic $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/main3.tex", tex(land) label dec(3) replace ctitle(PPML) keep(c.policy3lag##highinfo_coo $dyadic $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo ewinfo3: ppmlhdfe combinedrate c.ewpolicy3lag##highinfo_coo $dyadic $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/main3.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.ewpolicy3lag##highinfo_coo $dyadic $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo tek3: ppmlhdfe combinedrate c.policy3lag##tek $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/main3.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.policy3lag##tek $dyadnum $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo ewtek3: ppmlhdfe combinedrate c.ewpolicy3lag##tek $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/main3.tex", tex(land) label dec(3) append ctitle(PPML)keep(c.ewpolicy3lag##tek $dyadnum $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo teknum3: ppmlhdfe combinedrate c.policy3lag##c.teknum $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/main3.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.policy3lag##c.teknum $dyadnum $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo ewteknum3: ppmlhdfe combinedrate c.ewpolicy3lag##c.teknum $dyadnum $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/main3.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.ewpolicy3lag##c.teknum $dyadnum $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')


********************************************************** TOBIT **********************************************************************************************************************************************************

eststo tinfo: tobit combinedrate c.policy5ma##highinfo_coo $dyadic $full i.ccode1 i.ccode2 i.year, vce(cl dyad_id) ll(0)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/tobit.tex", tex(land) label dec(3) replace ctitle(PPML) keep(c.policy5ma##highinfo_coo $dyadic $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo tewinfo: tobit combinedrate c.ewpolicy5ma##highinfo_coo $dyadic $full i.ccode1 i.ccode2 i.year, vce(cl dyad_id) ll(0)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/tobit.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.ewpolicy5ma##highinfo_coo $dyadic $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo ttek: tobit combinedrate c.policy5ma##tek $dyadnum $full i.ccode1 i.ccode2 i.year, vce(cl dyad_id) ll(0)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/tobit.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.policy5ma##tek $dyadnum $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo tewtek: tobit combinedrate c.ewpolicy5ma##tek $dyadnum $full i.ccode1 i.ccode2 i.year, vce(cl dyad_id) ll(0)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/tobit.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.ewpolicy5ma##tek $dyadnum $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo tteknum: tobit combinedrate c.policy5ma##c.teknum $dyadnum $full i.ccode1 i.ccode2 i.year, vce(cl dyad_id) ll(0)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/tobit.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.policy5ma##c.teknum $dyadnum $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo tewteknum: tobit combinedrate c.ewpolicy5ma##c.teknum $dyadnum $full i.ccode1 i.ccode2 i.year, vce(cl dyad_id) ll(0)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/tobit.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.ewpolicy5ma##c.teknum $dyadnum $full) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')


********************************************************** 1992 Arrivals **********************************************************************************************************************************************************

eststo info92: ppmlhdfe arrivalrate92 c.policy5ma##highinfo_coo tek $dyad92 $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/arrival92.tex", tex(land) label dec(3) replace ctitle(PPML) keep(c.policy5ma##highinfo_coo) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo ewinfo92: ppmlhdfe arrivalrate92 c.ewpolicy5ma##highinfo_coo tek $dyad92 $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/arrival92.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.ewpolicy5ma##highinfo_coo) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo tek92: ppmlhdfe arrivalrate92 c.policy5ma##tek $dyad92 $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/arrival92.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.policy5ma##tek) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo ewtek92: ppmlhdfe arrivalrate92 c.ewpolicy5ma##tek $dyad92 $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/arrival92.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.ewpolicy5ma##tek) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo teknum92: ppmlhdfe arrivalrate92 c.policy5ma##c.teknum $dyad92 $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/arrival92.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.policy5ma##c.teknum) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')

eststo ewteknum92: ppmlhdfe arrivalrate92 c.ewpolicy5ma##c.teknum $dyad92 $full, cluster(dyad_id) abs(ccode1 ccode2 year)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
outreg2 using "~/Desktop/arrival92.tex", tex(land) label dec(3) append ctitle(PPML) keep(c.ewpolicy5ma##c.teknum) alpha(0.01, 0.05, 0.1) sym(***,**,*) addstat("Pseudo-R2", e(r2_p), "AIC", `AIC')


********************************************************** PANEL EVENT STUDY **********************************************************************************************************************************************************

use "gscm.dta", clear
estimates drop _all
global itsa "ihs_gdppc_lag1 polyarchy_lag1 ihs_pop_lag1 fariss_repression_lag1 ihs_unemployilo_lag1 cwbroad_lag1 majoranncwbroad_reg1500_lag1"

xtset ccode2 year

eventdd combinedarrivals $itsa, timevar(timetotreat) cluster(ccode2) method(hdfe, absorb(ccode2 year)) lags(15) leads(15) accum level(90) noend noline graph_op(xtitle("Time Relative to Treatment", size(medsmall)) ytitle("FDP Arrivals", size(medsmall)) ylabel(-50000(25000)100000) xlabel(-15(3)15, angle(h) tlength(*1.45)) xmtick(-15(1)15, tlength(*1.75)) xline(0, lcolor(red%75) lpatt(solid)) yline(0, lcolor(black) lpatt(shortdash)) legend(off))

eventdd tek_combinedarrivals $itsa, timevar(timetotreat) cluster(ccode2) method(hdfe, absorb(ccode2 year)) lags(15) leads(15) accum level(90) noend noline graph_op(xtitle("Time Relative to Treatment", size(medsmall)) ytitle("FDP Arrivals from TEK Origins", size(medsmall)) ylabel(-50000(25000)100000) xlabel(-15(3)15, angle(h) tlength(*1.45)) xmtick(-15(1)15, tlength(*1.75)) xline(0, lcolor(red%75) lpatt(solid)) yline(0, lcolor(black) lpatt(shortdash)) legend(off))


********************************************************** INTERRUPTED TIME SERIES **********************************************************************************************************************************************************

use "itsa.dta", clear
estimates drop _all
global itsa "ihs_gdppc_lag1 polyarchy_lag1 ihs_pop_lag1 fariss_repression_lag1 ihs_unemployilo_lag1 cwbroad_lag1 majoranncwbroad_reg1500_lag1"

xtset ccode2 year

*** LIBERALIZING REFORMS -- COMPARATIVE

itsa combinedarrivals $itsa, treat(490) trperiod(2002) contid(352 372 402 404 420 432 450 471 483 501 517 570 590 600 620 625 640 645 652 660 663 670 698 700 705 750 760) prais rhotype(tscorr) vce(cl ccode2) posttrend figure replace

itsa combinedarrivals $itsa, treat(530) trperiod(2004) contid(352 371 373 403 404 411 434 436 438 439 450 452 475 481 501 516 517 531 540 541 552 553 570 571 580 615 616 620 640 645 652 663 670 694 700 701 702 704 705 760 780 781 790) prais rhotype(tscorr) vce(cl ccode2) posttrend figure replace

itsa combinedarrivals $itsa, treat(471) trperiod(2005) contid(372 373 402 404 411 420 432 433 435 436 437 438 451 475 482 490 501 510 516 517 530 531 541 560 615 620 640 645 652 663 666 692 698 700 704 760) prais rhotype(tscorr) vce(cl ccode2) posttrend figure replace

itsa combinedarrivals $itsa, treat(501) trperiod(2006 2008) contid(352 371 372 373 402 403 404 411 420 432 433 435 436 437 438 439 451 452 461 471 475 481 482 483 484 510 516 517 520 522 530 531 540 541 551 552 553 565 570 571 572 580 581 590 600 615 616 620 640 645 652 660 666 670 679 690 692 694 696 698 700 701 702 703 704 705 750 760 771 780 781 790) prais rhotype(tscorr) vce(cl ccode2) posttrend figure replace

itsa combinedarrivals $itsa, treat(500) trperiod(2006) contid(352 371 373 402 411 433 435 437 438 439 450 451 452 481 482 483 484 490 522 530 540 541 552 565 570 571 581 625 640 645 652 660 666 670 690 698 700 701 702 703 705 750 780 781) prais rhotype(tscorr) vce(cl ccode2) posttrend figure replace

itsa combinedarrivals $itsa, treat(451) trperiod(2007) contid(437 450 483 484 500 522 530 560 625 630 640 645 651 660 663 700) prais rhotype(tscorr) vce(cl ccode2) posttrend figure replace

itsa combinedarrivals $itsa, treat(482) trperiod(2007) contid(352 372 373 402 403 404 411 420 432 433 434 436 437 438 439 450 452 461 471 475 481 483 484 490 500 501 510 516 517 520 522 530 531 540 541 551 552 553 560 565 570 571 572 580 581 590 600 615 616 625 640 645 651 660 663 666 670 679 690 692 694 696 698 700 701 702 703 704 705 750 760 780 781) prais rhotype(tscorr) vce(cl ccode2) posttrend figure replace

itsa combinedarrivals $itsa, treat(439) trperiod(2008) contid(352 371 372 373 402 403 404 411 432 433 435 436 438 450 452 475 481 482 484 500 501 517 530 531 540 552 565 571 572 580 615 620 640 645 660 663 666 670 679 690 692 694 698 700 701 703 750 760 771 780 781 790) prais rhotype(tscorr) vce(cl ccode2) posttrend figure replace

itsa combinedarrivals $itsa, treat(420) trperiod(2008) contid(352 371 372 373 402 403 411 433 434 435 436 438 450 452 471 475 481 482 484 501 516 517 520 522 530 531 540 541 570 571 572 581 600 615 620 645 651 663 666 670 692 694 696 698 700 701 702 703 704 705 760 771 780 781 790) prais rhotype(tscorr) vce(cl ccode2) posttrend figure replace

itsa combinedarrivals $itsa, treat(404) trperiod(2008) contid(371 372 373 402 403 411 432 433 435 436 438 439 450 452 471 475 482 484 501 516 517 520 522 530 531 540 541 551 571 572 581 590 600 615 616 620 625 645 660 663 666 670 679 700 703 704 705 760 780 781) prais rhotype(tscorr) vce(cl ccode2) posttrend figure replace

itsa combinedarrivals $itsa, treat(705) trperiod(2009) contid(352 372 373 403 404 411 420 432 434 435 436 437 438 450 452 461 483 484 490 500 517 520 522 530 531 540 552 560 565 570 571 615 616 625 630 640 651 652 663 666 679 692 696 700 702 703 770 771 780 790) prais rhotype(tscorr) vce(cl ccode2) posttrend figure replace

itsa combinedarrivals $itsa, treat(625) trperiod(2014) contid(352 371 372 373 404 411 420 432 433 434 435 436 437 438 439 450 451 452 461 471 475 481 482 483 484 490 500 510 516 520 522 530 531 540 551 552 553 572 580 581 615 616 620 630 640 666 679 690 692 694 696 698 700 701 702 703 705 750 760 770 771 781 790) prais rhotype(tscorr) vce(cl ccode2) posttrend figure replace


*** RESTRICTIVE REFORMS -- COMPARATIVE

itsa combinedarrivals $itsa, treat(705) trperiod(2004) contid(372 373 402 411 420 433 435 436 450 452 461 475 481 490 501 516 517 520 522 530 552 553 560 570 590 616 620 625 640 645 651 652 660 663 666 690 692 694 700 703 760) prais rhotype(tscorr) vce(cl ccode2) posttrend figure replace

itsa combinedarrivals $itsa, treat(501) trperiod(2007) contid(352 371 372 373 402 403 404 411 420 432 433 434 435 436 438 439 450 452 461 475 481 482 483 484 490 510 516 517 520 522 530 531 540 541 551 552 553 560 565 570 571 572 580 581 590 600 615 616 620 640 645 651 660 666 670 690 692 694 696 698 700 701 702 703 704 705 750 760 771 780 781 790) prais rhotype(tscorr) vce(cl ccode2) posttrend figure replace

itsa combinedarrivals $itsa, treat(371) trperiod(2009) contid(352 373 404 420 433 434 435 436 437 438 439 450 451 452 461 471 481 483 484 500 501 516 517 520 522 530 540 541 552 560 571 600 615 616 620 625 630 640 645 651 652 660 663 666 679 690 692 694 696 698 700 702 770) prais rhotype(tscorr) vce(cl ccode2) posttrend figure replace

itsa combinedarrivals $itsa, treat(373) trperiod(2013) contid(352 372 411 420 432 434 435 436 438 439 450 451 461 471 482 483 484 500 501 520 522 530 540 541 551 553 560 565 571 572 600 616 625 630 640 645 651 652 660 663 666 670 690 692 694 696 700 702 703 705 770 781) prais rhotype(tscorr) vce(cl ccode2) posttrend figure replace

itsa combinedarrivals $itsa, treat(640) trperiod(2013) contid(352 371 372 373 402 403 404 411 420 432 433 434 435 436 437 438 439 450 451 452 461 471 475 481 482 484 490 500 501 510 516 517 520 522 530 531 540 541 551 552 553 560 565 570 571 572 580 581 590 600 615 620 625 645 651 652 660 663 666 670 679 690 692 694 698 700 701 702 703 704 705 750 760 771 780 790) prais rhotype(tscorr) vce(cl ccode2) posttrend figure replace

itsa combinedarrivals $itsa, treat(475) trperiod(2015) contid(352 372 403 411 420 432 433 434 435 436 438 450 451 452 461 482 483 500 501 517 520 522 531 540 552 553 560 565 570 571 572 580 581 590 600 616 620 625 652 670 694 696 700 701 703 705 750 770 771 790) prais rhotype(tscorr) vce(cl ccode2) posttrend figure replace


****************************************** UGANDA OVER TIME **********************************************

preserve

keep if ccode2==500

collapse (sum) combinedarrivals asylumstock applications_popstat newrefugees newrefugees_fill newarrrivals (max) icw_index_field2_5ma, by(year)

replace icw_index_field2_5ma=icw_index_field2_5ma-1

twoway line combinedarrivals year if year>=2000, yaxis(2) || (line newrefugees_fill year if inrange(year,1960,2000), yaxis(2) lcolor(black) lpattern (1 1)) || line icw_index_field2_5ma year if year>=1960, yaxis(1) legend(off) ylabel(0(.1)1, angle(h) tlength(*1.45) axis(1)) ymtick(##2, tlength(*1.75) axis(1)) xtitle("Year", size(medsmall)) xlabel(1960(3)2017, angle(45) tlength(*1.45)) xmtick(1960(1)2017, tlength(*1.75)) lc(cranberry black black black) lpattern(- 1 1 1) ylabel(0(50000)550000, angle(h) tlength(*1.45) axis(2)) ymtick(##2, tlength(*1.75) axis(2)) ytitle("Forced Migrant Arrivals", size(medsmall) axis(2)) ytitle("Asylum Policy Index", size(medsmall) axis(1)) saving(ugandapolicytrend.gph, replace)

restore
